﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Agnes.Core;
using Caliburn.Micro;

namespace Agnes.TaskManager
{
    public class TaskPad : IWorkbenchPad
    {
        private static TaskPadView _taskPadView = null;

        private static TaskPadViewModel _taskPadViewModel = null;

        public object Content
        {
            get 
            {
                if (_taskPadView == null)
                {
                    _taskPadView = new TaskPadView();
                    _taskPadViewModel = new TaskPadViewModel(TaskManagerService.TaskManager);
                    ViewModelBinder.Bind(_taskPadViewModel, _taskPadView, null);
                }

                return _taskPadView;
            }
        }

        public string ImageUri
        {
            get 
            {
                return "";
            }
        }

        public bool IsHide { get; set; }

        public void SlnClosed(object sender, EventArgs e)
        {
            if (_taskPadViewModel != null)
            {
                _taskPadViewModel.Model = null;
            }
        }

        public void SlnOpened(object sender, EventArgs e)
        {
            if (_taskPadViewModel != null)
            {
                _taskPadViewModel.Model = TaskManagerService.TaskManager;
            }
        }

        public string Title
        {
            get 
            {
                return "最近任务";
            }
        }

        public WorkbenchPadPosition WorkbenchPadPosition
        {
            get 
            {
                return Core.WorkbenchPadPosition.Left;
            }
        }
    }
}
